package wiki.xsx.core.snowflake.config.nacos;

import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
import com.alibaba.cloud.nacos.discovery.NacosDiscoveryClient;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Configuration;
import wiki.xsx.core.snowflake.config.DiscoveryConfig;

import javax.annotation.Resource;

/**
 * nacos配置
 * @author xsx
 * @date 2019/11/20
 * @since 1.8
 */
@Configuration("snowflakeDiscoveryConfig")
@ConditionalOnClass({
        NacosDiscoveryClient.class,
        NacosDiscoveryProperties.class
})
public class NacosDiscoveryConfig implements DiscoveryConfig {

    @Resource(type = NacosDiscoveryProperties.class)
    private NacosDiscoveryProperties properties;

    /**
     * 获取服务名称
     */
    @Override
    public String getServiceName() {
        return this.properties.getService();
    }
}
